package com.lishe.lishe.lishe.module.excitation.adapter;

import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.lishe.lishe.Imageloader.ImageLoaderUtils;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.MyRecyclerView.RecyclerviewBaseAdapter;
import com.lishe.lishe.lishe.module.excitation.bean.admire.AdmireObject;
import com.lishe.lishe.lishe.utils.TimeUtils;

import java.util.List;

/**
 * Created by DELL on 2017/10/26.
 */

public class PersonReceiveAdmireAdapter extends RecyclerviewBaseAdapter {

    private Activity mContext;
    private List<AdmireObject> mList;

    public PersonReceiveAdmireAdapter(Activity context, List<AdmireObject> list){
        this.mContext=context;
        this.mList=list;
    }

    @Override
    public MyViewHolder onCreateViewHolderMy(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_person_admire_list,null);
        MyViewHolder holder=new MyViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolderMy(final RecyclerView.ViewHolder holder, int position) {
        AdmireObject admireObject=mList.get(position);
        if(!TextUtils.isEmpty(admireObject.getAvatarPath()))
            ImageLoaderUtils.displayImage(mContext,admireObject.getAvatarPath(),((MyViewHolder) holder).head);
        ((MyViewHolder) holder).name.setText(admireObject.getUserName()+"  ");
        ((MyViewHolder) holder).time.setText(TimeUtils.longToyyyyMMddHHmm(admireObject.getCreateTime()));
    }

    @Override
    public int getItemCountMy() {
        return mList.size();
    }

    @Override
    public int getItemViewTypeMy(int position) {
        return 0;
    }

    class MyViewHolder extends RecyclerView.ViewHolder{
        private ImageView head;
        private TextView name,time;

        public MyViewHolder(View itemView) {
            super(itemView);
            head=itemView.findViewById(R.id.head);
            name=itemView.findViewById(R.id.name);
            time=itemView.findViewById(R.id.time);
        }
    }


}
